package com.xz.disk.utils;

import lombok.Data;

import java.util.Map;

/**
 * ========================================================
 * ******************【学如逆水行舟】***********************
 * 如果能力跟不上野心的步伐，那就停下天马行空的想象，继续努力吧！！！
 *
 * @author ：肖舟   XiaoZhou
 * @date ：Created in 2020/3/16 19:46
 * *********************【不进则退】************************
 * ========================================================
 */
@Data
public class Page {

    private Integer pageIndex;
    private Integer pageSize;
    private Integer pageCount;
    private Integer rowCount;
    private Map<String,Object> params;

    // 获得查询参数
    public Map<String,Object> getParams(){
        if(rowCount!=null){
            params.put("firstRow",getFirstRow());
            params.put("pageSize",pageSize);
        }
        return params;
    }


    public Integer getPageCount(){
        return rowCount%pageSize==0?rowCount/pageSize:rowCount/pageSize+1;
    }

    public Integer getFirstRow(){
        return (pageIndex-1)*pageSize;
    }
}
